package com.itheima.controller;


import com.itheima.pojo.User;
import com.itheima.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

//    @Value("${server.port}")
//    private Integer port;

    @GetMapping("/{id}")
    public User findUserById(@PathVariable("id") String username,
                             HttpServletRequest request){
//        log.info("Server port is :"+port);
        System.out.println(request.getHeader("name"));
        return userService.findUserById(username);
    }
}
